
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>JNI例子 · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-versions-select/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../SDL/SDL基础.html" />
    
    
    <link rel="prev" href="JNI基础.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../linux/linux基础.html">
            
                <a href="../linux/linux基础.html">
            
                    
                    linux
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../linux/linux基础.html">
            
                <a href="../linux/linux基础.html">
            
                    
                    linux基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../linux/android底层开发.html">
            
                <a href="../linux/android底层开发.html">
            
                    
                    android底层开发
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../c语言/c基础.html">
            
                <a href="../c语言/c基础.html">
            
                    
                    c
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../c语言/c基础.html">
            
                <a href="../c语言/c基础.html">
            
                    
                    c基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../c++/c++基础.html">
            
                <a href="../c++/c++基础.html">
            
                    
                    c++
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../c++/c++基础.html">
            
                <a href="../c++/c++基础.html">
            
                    
                    c++基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../QT/QT基础.html">
            
                <a href="../QT/QT基础.html">
            
                    
                    QT
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../QT/QT基础.html">
            
                <a href="../QT/QT基础.html">
            
                    
                    QT基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="JNI基础.html">
            
                <a href="JNI基础.html">
            
                    
                    JNI
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="JNI基础.html">
            
                <a href="JNI基础.html">
            
                    
                    JNI基础
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6.2" data-path="JNI例子.html">
            
                <a href="JNI例子.html">
            
                    
                    JNI例子
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../SDL/SDL基础.html">
            
                <a href="../SDL/SDL基础.html">
            
                    
                    SDL
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../SDL/SDL基础.html">
            
                <a href="../SDL/SDL基础.html">
            
                    
                    SDL基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../ffmpeg/ffmpeg基础.html">
            
                <a href="../ffmpeg/ffmpeg基础.html">
            
                    
                    ffmpeg
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../ffmpeg/ffmpeg基础.html">
            
                <a href="../ffmpeg/ffmpeg基础.html">
            
                    
                    ffmpeg基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../ffmpeg/ffmpeg示例代码.html">
            
                <a href="../ffmpeg/ffmpeg示例代码.html">
            
                    
                    ffmpeg示例代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../ffmpeg/ffmpeg软解rtsp简单直播.html">
            
                <a href="../ffmpeg/ffmpeg软解rtsp简单直播.html">
            
                    
                    ffmpeg软解rtsp简单直播
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../ffmpeg/rtsp服务器.html">
            
                <a href="../ffmpeg/rtsp服务器.html">
            
                    
                    rtsp服务器Windows
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../opencv/opencv模块.html">
            
                <a href="../opencv/opencv模块.html">
            
                    
                    opencv模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../opencv/opencv.html">
            
                <a href="../opencv/opencv.html">
            
                    
                    opencv
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../openSLES/openSLES基础.html">
            
                <a href="../openSLES/openSLES基础.html">
            
                    
                    openSLES
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../openSLES/openSLES基础.html">
            
                <a href="../openSLES/openSLES基础.html">
            
                    
                    openSLES基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../SoundTouch/移植SoundTouch.html">
            
                <a href="../SoundTouch/移植SoundTouch.html">
            
                    
                    SoundTouch
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../SoundTouch/移植SoundTouch.html">
            
                <a href="../SoundTouch/移植SoundTouch.html">
            
                    
                    移植SoundTouch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../SoundTouch/实现音频变速和变调.html">
            
                <a href="../SoundTouch/实现音频变速和变调.html">
            
                    
                    实现音频变速和变调
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../openGLES/openGLES基础.html">
            
                <a href="../openGLES/openGLES基础.html">
            
                    
                    openGLES模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../openGLES/GLSL基础.html">
            
                <a href="../openGLES/GLSL基础.html">
            
                    
                    GLSL基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../openGLES/openglES示例.html">
            
                <a href="../openGLES/openglES示例.html">
            
                    
                    openglES示例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../视频相关/音视频基础.html">
            
                <a href="../视频相关/音视频基础.html">
            
                    
                    音视频术语-文件格式-协议
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../视频相关/音视频基础.html">
            
                <a href="../视频相关/音视频基础.html">
            
                    
                    音视频基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../视频相关/RTSP.html">
            
                <a href="../视频相关/RTSP.html">
            
                    
                    RTSP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../视频相关/RTP.html">
            
                <a href="../视频相关/RTP.html">
            
                    
                    RTP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="../视频相关/RTCP.html">
            
                <a href="../视频相关/RTCP.html">
            
                    
                    RTCP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" data-path="../视频相关/H264.html">
            
                <a href="../视频相关/H264.html">
            
                    
                    H264
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.6" data-path="../视频相关/YUV.html">
            
                <a href="../视频相关/YUV.html">
            
                    
                    YUV
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.7" data-path="../视频相关/SurfaceView.html">
            
                <a href="../视频相关/SurfaceView.html">
            
                    
                    SurfaceView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.8" data-path="../视频相关/RTMP.html">
            
                <a href="../视频相关/RTMP.html">
            
                    
                    RTMP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.9" data-path="../视频相关/AAC详解.html">
            
                <a href="../视频相关/AAC详解.html">
            
                    
                    AAC详解
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../音视频相关代码/音视频相关代码.html">
            
                <a href="../音视频相关代码/音视频相关代码.html">
            
                    
                    音视频相关代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../ndk/NDK编译基础.html">
            
                <a href="../ndk/NDK编译基础.html">
            
                    
                    NDK工程编译
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../ndk/NDK编译基础.html">
            
                <a href="../ndk/NDK编译基础.html">
            
                    
                    NDK编译基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../ndk/cmake方式.html">
            
                <a href="../ndk/cmake方式.html">
            
                    
                    cmake
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../ndk/Android.mk模板.html">
            
                <a href="../ndk/Android.mk模板.html">
            
                    
                    Android.mk
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4" data-path="../ndk/Application.mk模板.html">
            
                <a href="../ndk/Application.mk模板.html">
            
                    
                    Application.mk
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >JNI例子</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#jni&#x4F8B;&#x5B50;"><b>1. </b>JNI&#x4F8B;&#x5B50;</a></li><ul><li><span class="title-icon "></span><a href="#jni-demo"><b>1.1. </b>jni Demo</a></li><li><span class="title-icon "></span><a href="#jni&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x751F;&#x6210;&#x5DE5;&#x5177;"><b>1.2. </b>JNI&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x751F;&#x6210;&#x5DE5;&#x5177;</a></li><li><span class="title-icon "></span><a href="#posix-&#x7B80;&#x5355;&#x793A;&#x4F8B;"><b>1.3. </b>POSIX &#x7B80;&#x5355;&#x793A;&#x4F8B;</a></li><li><span class="title-icon "></span><a href="#tcp-socket-&#x7B80;&#x5355;&#x793A;&#x4F8B;"><b>1.4. </b>TCP socket &#x7B80;&#x5355;&#x793A;&#x4F8B;</a></li></ul></ul></div><a href="#jni&#x4F8B;&#x5B50;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="jni&#x4F8B;&#x5B50;"><a name="jni&#x4F8B;&#x5B50;" class="anchor-navigation-ex-anchor" href="#jni&#x4F8B;&#x5B50;"><i class="fa fa-link" aria-hidden="true"></i></a>1. JNI&#x4F8B;&#x5B50;</h1>
<h2 id="jni-demo"><a name="jni-demo" class="anchor-navigation-ex-anchor" href="#jni-demo"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. jni Demo</h2>
<p><a href="https://gitee.com/AivinPrivate/Android_Jni_cpp" target="_blank">jniSample</a> &#x6F14;&#x793A;&#x6548;&#x679C;&#xFF1A;</p>
<ul>
<li style="list-style: none"><input type="checkbox" disabled="disabled" checked="checked"> java&#x8C03;&#x7528;c++</li>
<li style="list-style: none"><input type="checkbox" disabled="disabled" checked="checked"> c++&#x56DE;&#x8C03;Java&#x51FD;&#x6570;</li>
<li style="list-style: none"><input type="checkbox" disabled="disabled" checked="checked"> c++&#x83B7;&#x53D6;&#x5E76;&#x4FEE;&#x6539;Java&#x9759;&#x6001;&#x53D8;&#x91CF;</li>
<li style="list-style: none"><input type="checkbox" disabled="disabled" checked="checked"> Java&#x5F00;&#x542F;&#x5B50;&#x7EBF;&#x7A0B;&#x8BA9;c++&#x6267;&#x884C;&#x8017;&#x65F6;&#x64CD;&#x4F5C;&#xFF0C;&#x5E76;&#x66F4;&#x65B0;Java ui</li>
<li style="list-style: none"><input type="checkbox" disabled="disabled" checked="checked"> &#x4F20;&#x9012;&#x5E76;&#x4FEE;&#x6539;&#x6570;&#x7EC4;</li>
<li style="list-style: none"><input type="checkbox" disabled="disabled" checked="checked"> c++&#x521B;&#x5EFA;Java&#x5B9A;&#x4E49;&#x7684;&#x5BF9;&#x8C61;&#x5E76;&#x8FD4;&#x56DE;</li>
<li style="list-style: none"><input type="checkbox" disabled="disabled"> c++&#x8C03;&#x7528;&#x7B2C;&#x4E09;&#x65B9;&#x5E93;&#x5B9E;&#x73B0;&#x52A0;&#x5BC6;&#x89E3;&#x5BC6;</li>
<li style="list-style: none"><input type="checkbox" disabled="disabled"> c++&#x8BFB;&#x53D6;&#x6587;&#x4EF6;</li>
<li style="list-style: none"><input type="checkbox" disabled="disabled"> c++&#x63A5;&#x6536;Java&#x4F20;&#x9012;&#x7684;&#x63A7;&#x4EF6; &#x5E76;&#x7ED8;&#x5236;&#x56FE;&#x50CF;</li>
<li style="list-style: none"><input type="checkbox" disabled="disabled" checked="checked"> c++&#x83B7;&#x53D6;apk&#x5305;&#x540D;</li>
<li style="list-style: none"><input type="checkbox" disabled="disabled" checked="checked"> c++&#x83B7;&#x53D6;apk&#x7B7E;&#x540D; &#x54C8;&#x5E0C;&#x503C; (&#x7B7E;&#x540D;&#x6821;&#x9A8C;)</li>
</ul>
<h2 id="jni&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x751F;&#x6210;&#x5DE5;&#x5177;"><a name="jni&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x751F;&#x6210;&#x5DE5;&#x5177;" class="anchor-navigation-ex-anchor" href="#jni&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x751F;&#x6210;&#x5DE5;&#x5177;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. JNI&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x751F;&#x6210;&#x5DE5;&#x5177;</h2>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SignatureGen</span>
</span>{
    <span class="hljs-keyword">private</span>  <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> HashMap&lt;String,String&gt; Primitives = <span class="hljs-keyword">new</span> HashMap&lt;String, String&gt;();

    <span class="hljs-keyword">static</span>
    {
        Primitives.put(Void.class.getName(),<span class="hljs-string">&quot;V&quot;</span>);
        Primitives.put(Boolean.class.getName(),<span class="hljs-string">&quot;Z&quot;</span>);
        Primitives.put(Byte.class.getName(),<span class="hljs-string">&quot;B&quot;</span>);
        Primitives.put(Character.class.getName(),<span class="hljs-string">&quot;C&quot;</span>);
        Primitives.put(Short.class.getName(),<span class="hljs-string">&quot;S&quot;</span>);
        Primitives.put(Integer.class.getName(),<span class="hljs-string">&quot;I&quot;</span>);
        Primitives.put(Long.class.getName(),<span class="hljs-string">&quot;J&quot;</span>);
        Primitives.put(Float.class.getName(),<span class="hljs-string">&quot;F&quot;</span>);
        Primitives.put(Double.class.getName(),<span class="hljs-string">&quot;D&quot;</span>);                
    }

    <span class="hljs-comment">/**
     * <span class="hljs-doctag">@param</span> &#x8FD4;&#x56DE;&#x503C;&#x7684;&#x7C7B;&#x578B;
     * <span class="hljs-doctag">@param</span> params &#x53C2;&#x6570;&#x7C7B;&#x578B;
     * <span class="hljs-doctag">@return</span> &#x7B7E;&#x540D;
     */</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> String <span class="hljs-title">getSignature</span><span class="hljs-params">( Class ret, Class...params )</span>
    </span>{
        StringBuilder builder = <span class="hljs-keyword">new</span> StringBuilder();
        builder.append(<span class="hljs-string">&quot;(&quot;</span>);
        <span class="hljs-keyword">for</span>( Class param : params ) {
            builder.append(getSignature(param));
        }        
        builder.append(<span class="hljs-string">&quot;)&quot;</span>);
        builder.append(getSignature(ret));
        <span class="hljs-keyword">return</span> builder.toString();
    }

    <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> String <span class="hljs-title">getSignature</span><span class="hljs-params">( Class  param )</span>
    </span>{
        StringBuilder builder = <span class="hljs-keyword">new</span> StringBuilder();
        String name = <span class="hljs-string">&quot;&quot;</span>;
        <span class="hljs-keyword">if</span>( param.isArray() )
        {
            name = param.getComponentType().getName();
            builder.append(<span class="hljs-string">&quot;[&quot;</span>);
        }<span class="hljs-keyword">else</span> {
            name = param.getName();                
        }

        <span class="hljs-keyword">if</span>( Primitives.containsKey(name) )
        {
            builder.append(Primitives.get(name));
        }
        <span class="hljs-keyword">else</span> {            
            builder.append(<span class="hljs-string">&quot;L&quot;</span>+name.replace(<span class="hljs-string">&quot;.&quot;</span>,<span class="hljs-string">&quot;/&quot;</span>)+<span class="hljs-string">&quot;;&quot;</span>);
        }

        <span class="hljs-keyword">return</span> builder.toString();
    }

}

<span class="hljs-comment">//&#x4F7F;&#x7528;&#x65B9;&#x6CD5;</span>
<span class="hljs-comment">//&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B; &#xFF0C;&#x540E;&#x9762;&#x7684;&#x53C2;&#x6570;&#x662F;&#x53C2;&#x6570;&#x7C7B;&#x578B;</span>
&#x4F8B;&#x5982;&#x9700;&#x8981;&#x83B7;&#x5F97;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x7684;&#x7B7E;&#x540D;&#xFF1A;
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">func</span><span class="hljs-params">(<span class="hljs-keyword">boolean</span> a,String b)</span>
<span class="hljs-comment">//&#x53C2;&#x6570;&#x5E94;&#x8BE5;&#x8FD9;&#x6837;&#x586B;&#x5199;</span>
SignatureGen.<span class="hljs-title">getSignature</span><span class="hljs-params">(Integer.class,Boolean.class,String.class)</span>)</span>;
<span class="hljs-comment">//&#x83B7;&#x5F97;&#x7B7E;&#x540D;&#x5982;&#x4E0B;</span>
(ZLjava/lang/String;)I
</code></pre>
<h2 id="posix-&#x7B80;&#x5355;&#x793A;&#x4F8B;"><a name="posix-&#x7B80;&#x5355;&#x793A;&#x4F8B;" class="anchor-navigation-ex-anchor" href="#posix-&#x7B80;&#x5355;&#x793A;&#x4F8B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. POSIX &#x7B80;&#x5355;&#x793A;&#x4F8B;</h2>
<pre><code class="lang-c"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;jni.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;wkplayer.h&quot;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;pthread.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;unistd.h&gt;</span></span>
JavaVM* java_vm = <span class="hljs-literal">NULL</span>;
<span class="hljs-keyword">pthread_mutex_t</span> mutex;
<span class="hljs-comment">// &#x5168;&#x5C40; &#x56DE;&#x8C03;&#x5BF9;&#x8C61;</span>
jobject callback = <span class="hljs-literal">NULL</span>;
<span class="hljs-comment">// &#x5168;&#x5C40;&#x56DE;&#x8C03;&#x51FD;&#x6570;</span>
jmethodID gOnNativeMessage = <span class="hljs-literal">NULL</span>;

<span class="hljs-comment">//&#x4F20;&#x9012;pthread&#x53C2;&#x6570;&#x7528;&#x7684;&#x7ED3;&#x6784;&#x4F53;</span>
<span class="hljs-keyword">struct</span> NativeWorkerArgs
{
    jint id;
    <span class="hljs-keyword">char</span>  reslut[<span class="hljs-number">20</span>];
};

<span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span>
<span class="hljs-function">JNIEXPORT <span class="hljs-keyword">void</span> JNICALL
<span class="hljs-title">Java_com_walkera_cn_ffmpegforandoriddemo_FFmpegPlayer_playMyMedia</span><span class="hljs-params">(JNIEnv *env, jobject instance, jstring url_)</span>
</span>{
    <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *url = env-&gt;GetStringUTFChars(  url_, <span class="hljs-number">0</span>);
    LOGI(<span class="hljs-string">&quot;url:%s&quot;</span>, url);
    env-&gt;ReleaseStringUTFChars( url_, url);
    <span class="hljs-comment">// &#x5728;&#x903B;&#x8F91;&#x9700;&#x8981;&#x7684;&#x65F6;&#x5019;&#x5F00;&#x542F;&#x5B50;&#x7EBF;&#x7A0B;&#xFF0C;&#x5E76;&#x5728;&#x5B50;&#x7EBF;&#x7A0B;&#x4E2D;&#x56DE;&#x8C03;java&#x51FD;&#x6570;</span>
    <span class="hljs-keyword">pthread_t</span>  handle ;
    <span class="hljs-comment">//&#x4F20;&#x5230;&#x5B50;&#x7EBF;&#x7A0B;&#x4E2D;&#x7684;&#x53C2;&#x6570;</span>
    NativeWorkerArgs* nativeWorkArgs = <span class="hljs-keyword">new</span> NativeWorkerArgs();
    nativeWorkArgs-&gt;id = <span class="hljs-number">100</span>;
    <span class="hljs-built_in">strcpy</span>(nativeWorkArgs-&gt;reslut , <span class="hljs-string">&quot;&#x767B;&#x5F55;&#x6210;&#x529F;&#xFF01;&quot;</span>);
    <span class="hljs-comment">//&#x521B;&#x5EFA;&#x7EBF;&#x7A0B; 0 &#x4EE3;&#x8868;&#x6210;&#x529F;</span>
    <span class="hljs-keyword">int</span> result = pthread_create(&amp;handle, <span class="hljs-literal">NULL</span>, nativeWorkerThread, (<span class="hljs-keyword">void</span>*) nativeWorkArgs);
}

<span class="hljs-comment">//&#x5B50;&#x7EBF;&#x7A0B; &#x6267;&#x884C;&#x7684;&#x51FD;&#x6570;</span>
<span class="hljs-function"><span class="hljs-keyword">void</span>* <span class="hljs-title">nativeWorkerThread</span><span class="hljs-params">(<span class="hljs-keyword">void</span>* args)</span>
</span>{
    JNIEnv* env = <span class="hljs-literal">NULL</span>;

    <span class="hljs-keyword">if</span> ( <span class="hljs-number">0</span> == java_vm-&gt;AttachCurrentThread(&amp;env, <span class="hljs-literal">NULL</span>))
    {
        <span class="hljs-comment">//lock</span>
        <span class="hljs-keyword">if</span> (<span class="hljs-number">0</span> != pthread_mutex_lock(&amp;mutex))
        {
            jclass exceptionClazz = env-&gt;FindClass(<span class="hljs-string">&quot;java/lang/RuntimeException&quot;</span>);
            env-&gt;ThrowNew(exceptionClazz, <span class="hljs-string">&quot;Unable to lock mutex--&quot;</span>);
        }
        NativeWorkerArgs* nativeWorkerAgrs = (NativeWorkerArgs*) args;
        <span class="hljs-comment">// &#x6A21;&#x62DF;&#x5EF6;&#x65F6; &#xFF0C;3&#x79D2;</span>
        sleep(<span class="hljs-number">2</span>);
        LOGI(<span class="hljs-string">&quot;&#x53C2;&#x6570;=== %d , %s  &quot;</span> ,nativeWorkerAgrs-&gt;id ,nativeWorkerAgrs-&gt;reslut);
        env-&gt;CallVoidMethod(  callback, gOnNativeMessage, nativeWorkerAgrs-&gt;id , env-&gt;NewStringUTF(nativeWorkerAgrs-&gt;reslut)   );
        <span class="hljs-keyword">delete</span> nativeWorkerAgrs;
        java_vm-&gt;DetachCurrentThread();

        <span class="hljs-keyword">if</span> (<span class="hljs-number">0</span> != pthread_mutex_unlock(&amp;mutex))
        {
            jclass exceptionClazz = env-&gt;FindClass(<span class="hljs-string">&quot;java/lang/RuntimeException&quot;</span>);
            env-&gt;ThrowNew(exceptionClazz, <span class="hljs-string">&quot;Unable to unlock mutex--&quot;</span>);
        }
    }
    <span class="hljs-keyword">return</span> <span class="hljs-literal">NULL</span>;
}

<span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span>
<span class="hljs-function">JNIEXPORT <span class="hljs-keyword">void</span> JNICALL
<span class="hljs-title">Java_com_walkera_cn_ffmpegforandoriddemo_FFmpegPlayer_setNativeCallback</span><span class="hljs-params">(JNIEnv *env,
                                                                        jobject instance,
                                                                        jobject callback0)</span>
</span>{

    <span class="hljs-keyword">if</span> (<span class="hljs-literal">NULL</span> == callback)
    {
        callback = env-&gt;NewGlobalRef(callback0);
    }

    <span class="hljs-comment">//&#x521D;&#x59CB;java&#x56DE;&#x8C03;</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-literal">NULL</span> == gOnNativeMessage)
    {
        jclass clazz = env-&gt;GetObjectClass(callback);
        gOnNativeMessage = env-&gt;GetMethodID(clazz, <span class="hljs-string">&quot;callbackForNative&quot;</span>, <span class="hljs-string">&quot;(ILjava/lang/String;)V&quot;</span>);
    }

  }

<span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span>
<span class="hljs-function">JNIEXPORT <span class="hljs-keyword">void</span> JNICALL
<span class="hljs-title">Java_com_walkera_cn_ffmpegforandoriddemo_FFmpegPlayer_initNative</span><span class="hljs-params">(JNIEnv *env, jobject instance)</span>
</span>{
    <span class="hljs-comment">//&#x521D;&#x59CB;&#x5316;&#x4E92;&#x65A5;&#x91CF;</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-number">0</span> != pthread_mutex_init(&amp;mutex, <span class="hljs-literal">NULL</span>))
    {
        jclass exceptionClazz = env-&gt;FindClass(<span class="hljs-string">&quot;java/lang/RuntimeException&quot;</span>);
        env-&gt;ThrowNew(exceptionClazz, <span class="hljs-string">&quot;Unable to init mutex&quot;</span>);
    }

}

<span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span>
<span class="hljs-function">JNIEXPORT <span class="hljs-keyword">void</span> JNICALL
<span class="hljs-title">Java_com_walkera_cn_ffmpegforandoriddemo_FFmpegPlayer_freeNative</span><span class="hljs-params">(JNIEnv *env, jobject instance)</span>
</span>{
    <span class="hljs-keyword">if</span> (<span class="hljs-literal">NULL</span> != callback)
    {
        env-&gt;DeleteGlobalRef(callback);
        callback = <span class="hljs-literal">NULL</span>;
    }

    <span class="hljs-comment">//&#x91CA;&#x653E;&#x4E92;&#x65A5;&#x91CF;</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-number">0</span> != pthread_mutex_destroy(&amp;mutex))
    {
        jclass exceptionClazz = env-&gt;FindClass(<span class="hljs-string">&quot;java/lang/RuntimeException&quot;</span>);
        env-&gt;ThrowNew(exceptionClazz, <span class="hljs-string">&quot;Unable to destroy mutex--&quot;</span>);
    }

}
</code></pre>
<h2 id="tcp-socket-&#x7B80;&#x5355;&#x793A;&#x4F8B;"><a name="tcp-socket-&#x7B80;&#x5355;&#x793A;&#x4F8B;" class="anchor-navigation-ex-anchor" href="#tcp-socket-&#x7B80;&#x5355;&#x793A;&#x4F8B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. TCP socket &#x7B80;&#x5355;&#x793A;&#x4F8B;</h2>
<p>&#x8BB0;&#x5F97;&#x5728;&#x5B50;&#x7EBF;&#x7A0B;&#x4E2D;&#x8FDB;&#x7A0B;&#x7F51;&#x7EDC;&#x8017;&#x65F6;&#x64CD;&#x4F5C;&#x3002;
<del>&#x7528; ByteBuffer &#x65B9;&#x5F0F;&#x6D4B;&#x8BD5;&#x5931;&#x8D25;&#x3002;&#x8FD8;&#x6CA1;&#x627E;&#x5230;&#x539F;&#x56E0;&#x3002;</del></p>
<pre><code class="lang-java"><span class="hljs-comment">// java&#x7AEF;&#x5B9A;&#x4E49;&#x63A5;&#x53E3;</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">native</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">createSocket</span><span class="hljs-params">()</span></span>;
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">native</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">connectSocket</span><span class="hljs-params">(String ip, <span class="hljs-keyword">int</span> port)</span></span>;
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">native</span> <span class="hljs-keyword">int</span> <span class="hljs-title">recvSocket</span><span class="hljs-params">(<span class="hljs-keyword">byte</span>[] buffer, <span class="hljs-keyword">int</span> offset, <span class="hljs-keyword">int</span> count)</span></span>;
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">native</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">sendStringData</span><span class="hljs-params">(String sendData)</span></span>;
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">native</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">sendBytesData</span><span class="hljs-params">(<span class="hljs-keyword">byte</span>[] byteBuffer)</span></span>;
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">native</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">closeSocket</span><span class="hljs-params">()</span></span>;
</code></pre>
<p><br></p>
<pre><code class="lang-c++"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;jni.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;stdio.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;unistd.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;sys/socket.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;netinet/in.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;arpa/inet.h&gt;</span></span>

JavaVM* java_vm = <span class="hljs-literal">NULL</span>;
<span class="hljs-keyword">int</span> sockId;
<span class="hljs-comment">// &#x521B;&#x5EFA;socket</span>
<span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span>
<span class="hljs-function">JNIEXPORT jboolean JNICALL
<span class="hljs-title">Java_com_walkera_cn_ffmpegforandoriddemo_TcpClinet_createSocket</span><span class="hljs-params">(JNIEnv *env, jobject instance)</span>
</span>{
    sockId = socket(AF_INET, SOCK_STREAM, <span class="hljs-number">0</span>) ;
    <span class="hljs-keyword">if</span>(sockId&lt;<span class="hljs-number">0</span>)
    {
        <span class="hljs-keyword">return</span> JNI_FALSE;
    }<span class="hljs-keyword">else</span>{
        <span class="hljs-keyword">return</span> JNI_TRUE;
    }
}

<span class="hljs-comment">// &#x8FDE;&#x63A5; socket</span>
<span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span>
<span class="hljs-function">JNIEXPORT jboolean JNICALL
<span class="hljs-title">Java_com_walkera_cn_ffmpegforandoriddemo_TcpClinet_connectSocket</span><span class="hljs-params">(JNIEnv *env, jobject instance,
                                                                 jstring ip_, jint port)</span>
</span>{
    <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *ip =env -&gt;GetStringUTFChars(  ip_, <span class="hljs-number">0</span>);
    <span class="hljs-keyword">struct</span> sockaddr_in servaddr;
    <span class="hljs-built_in">memset</span>(&amp;servaddr, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_port = htons(port);

    <span class="hljs-keyword">if</span> (inet_pton(AF_INET, ip, &amp;servaddr.sin_addr) &lt;= <span class="hljs-number">0</span>) {
        <span class="hljs-keyword">return</span> JNI_FALSE;
    }
    <span class="hljs-keyword">if</span> (connect(sockId, (<span class="hljs-keyword">struct</span> sockaddr *) &amp;servaddr, <span class="hljs-keyword">sizeof</span>(servaddr)) &lt; <span class="hljs-number">0</span>) {
        <span class="hljs-keyword">return</span> JNI_FALSE;
    }
    env-&gt;ReleaseStringUTFChars(   ip_, ip);
    <span class="hljs-keyword">return</span> JNI_TRUE;

}

<span class="hljs-comment">// &#x53D1;&#x9001; String &#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;</span>
<span class="hljs-comment">// &#x53D1;&#x9001;&#x4E2D;&#x6587; &#x4F1A;&#x6709;&#x4E71;&#x7801; &#x3002;</span>
<span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span>
<span class="hljs-function">JNIEXPORT jboolean JNICALL
<span class="hljs-title">Java_com_walkera_cn_ffmpegforandoriddemo_TcpClinet_sendStringData</span><span class="hljs-params">(JNIEnv *env, jobject instance,
                                                              jstring sendData_)</span> </span>{
    <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *sendData = env-&gt;GetStringUTFChars(   sendData_, <span class="hljs-number">0</span>);
    <span class="hljs-keyword">if</span> (!sockId)
    {
        jclass exceptionClazz = env-&gt;FindClass(<span class="hljs-string">&quot;java/lang/RuntimeException&quot;</span>);
        env-&gt;ThrowNew(exceptionClazz, <span class="hljs-string">&quot;socket&#x5DF2;&#x7ECF;&#x65AD;&#x5F00;&quot;</span>);
        <span class="hljs-keyword">return</span> JNI_FALSE;
    }
    <span class="hljs-comment">//LOGI(&quot;&#x53D1;&#x9001;%s=&quot; ,sendData);</span>
    fgets((<span class="hljs-keyword">char</span> *) sendData, <span class="hljs-number">1024</span>, <span class="hljs-built_in">stdin</span>);
    <span class="hljs-keyword">if</span> (send(sockId, sendData, <span class="hljs-built_in">strlen</span>(sendData), <span class="hljs-number">0</span>) &lt; <span class="hljs-number">0</span>) {
        <span class="hljs-keyword">return</span> JNI_FALSE;
    }
    env-&gt;ReleaseStringUTFChars(   sendData_, sendData);
    <span class="hljs-keyword">return</span> JNI_TRUE;
}

<span class="hljs-comment">// &#x53D1;&#x9001; byte[] &#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;</span>
<span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span>
<span class="hljs-function">JNIEXPORT jboolean JNICALL
<span class="hljs-title">Java_com_walkera_cn_ffmpegforandoriddemo_TcpClinet_sendBytesData</span><span class="hljs-params">(JNIEnv *env, jobject instance,
                                                                 jbyteArray byteBuffer_)</span> </span>{
    <span class="hljs-keyword">if</span> (!sockId)
    {
        jclass exceptionClazz = env-&gt;FindClass(<span class="hljs-string">&quot;java/lang/RuntimeException&quot;</span>);
        env-&gt;ThrowNew(exceptionClazz, <span class="hljs-string">&quot;socket&#x5DF2;&#x7ECF;&#x65AD;&#x5F00;&quot;</span>);
        <span class="hljs-keyword">return</span> JNI_FALSE;
    }

    jbyte* pBuffer =   env-&gt; GetByteArrayElements(byteBuffer_ , <span class="hljs-literal">NULL</span>);
    jint legth = env-&gt;GetArrayLength(byteBuffer_) ;

    <span class="hljs-keyword">if</span> (send(sockId, pBuffer, legth  , <span class="hljs-number">0</span>) &lt; <span class="hljs-number">0</span>)
    {
        <span class="hljs-keyword">return</span> JNI_FALSE;
    }
    env-&gt;ReleaseByteArrayElements(byteBuffer_, pBuffer, <span class="hljs-number">0</span>);
    <span class="hljs-keyword">return</span>  JNI_TRUE ;
}

<span class="hljs-comment">// &#x63A5;&#x6536;byte[]&#x4FE1;&#x606F;</span>
<span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span>
<span class="hljs-function">JNIEXPORT jint JNICALL
<span class="hljs-title">Java_com_walkera_cn_ffmpegforandoriddemo_TcpClinet_recvSocket</span><span class="hljs-params">(JNIEnv *env, jobject instance,
                                                              jbyteArray buffer_, jint offset,
                                                              jint count)</span> </span>{

    <span class="hljs-keyword">if</span> (!sockId)
    {
        jclass exceptionClazz = env-&gt;FindClass(<span class="hljs-string">&quot;java/lang/RuntimeException&quot;</span>);
        env-&gt;ThrowNew(exceptionClazz, <span class="hljs-string">&quot;socket&#x5DF2;&#x7ECF;&#x65AD;&#x5F00;&quot;</span>);
        <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
    }
    jbyte buf[count - offset];
    <span class="hljs-keyword">int</span> rec_len;
    <span class="hljs-keyword">if</span> ((rec_len = (<span class="hljs-keyword">int</span>) recv(sockId, buf, <span class="hljs-keyword">sizeof</span>(buf), <span class="hljs-number">0</span>)) == <span class="hljs-number">-1</span>)
    {
        jclass exceptionClazz = env-&gt;FindClass(<span class="hljs-string">&quot;java/lang/RuntimeException&quot;</span>);
        env-&gt;ThrowNew(exceptionClazz, <span class="hljs-string">&quot;native&#x63A5;&#x6536;&#x5F02;&#x5E38;&quot;</span>);
        <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
    }

    buf[rec_len] = <span class="hljs-string">&apos;\0&apos;</span>;
    <span class="hljs-comment">// &#x5C06;&#x672C;&#x5730;&#x6570;&#x636E;&#x62F7;&#x8D1D;&#x5230;java&#x7AEF;&#x7684;&#x6570;&#x7EC4;&#x4E2D;</span>
    env-&gt;SetByteArrayRegion( buffer_, offset, count, buf);
    env-&gt;DeleteLocalRef(buffer_);
    <span class="hljs-keyword">return</span> rec_len;

}

<span class="hljs-comment">// &#x5173;&#x95ED;&#x8FDE;&#x63A5;</span>
<span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span>
<span class="hljs-function">JNIEXPORT jboolean JNICALL
<span class="hljs-title">Java_com_walkera_cn_ffmpegforandoriddemo_TcpClinet_closeSocket</span><span class="hljs-params">(JNIEnv *env, jobject instance)</span>
</span>{
    <span class="hljs-keyword">int</span> reslut = close(sockId);
    <span class="hljs-comment">// &#x8FD4;&#x56DE;0 &#xFF0C;&#x5173;&#x95ED;&#x6210;&#x529F;</span>
    <span class="hljs-keyword">return</span> JNI_TRUE;

}

<span class="hljs-function">JNIEXPORT jint <span class="hljs-title">JNI_OnLoad</span><span class="hljs-params">(JavaVM* vm, <span class="hljs-keyword">void</span>* reserved)</span>
</span>{
    JNIEnv *env;
    <span class="hljs-keyword">if</span> (vm-&gt;GetEnv(  (<span class="hljs-keyword">void</span>**) &amp;env,  JNI_VERSION_1_4) != JNI_OK)
    {
        <span class="hljs-keyword">return</span> JNI_ERR ;
    }
    java_vm = vm;
    <span class="hljs-keyword">return</span> JNI_VERSION_1_4;
}
</code></pre>
<footer class="page-footer"><span class="copyright">&#x65E0;&#x7248;&#x6743; &#x53EF;&#x4EE5;&#x65E0;&#x9650;&#x5236;&#x4F7F;&#x7528;&#xFF01; all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2019-12-24 08:20:09
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="JNI基础.html" class="navigation navigation-prev " aria-label="Previous page: JNI基础">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../SDL/SDL基础.html" class="navigation navigation-next " aria-label="Next page: SDL">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"JNI例子","level":"1.6.2","depth":2,"next":{"title":"SDL","level":"1.7","depth":1,"path":"chinese/SDL/SDL基础.md","ref":"chinese/SDL/SDL基础.md","articles":[{"title":"SDL基础","level":"1.7.1","depth":2,"path":"chinese/SDL/SDL基础.md","ref":"chinese/SDL/SDL基础.md","articles":[]}]},"previous":{"title":"JNI基础","level":"1.6.1","depth":2,"path":"chinese/jni/JNI基础.md","ref":"chinese/jni/JNI基础.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","versions-select","fontsettings","sharing","tbfed-pagefooter","donate","local-video","splitter","edit-link","expandable-chapters","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"无版权 可以无限制使用！","modify_label":"该文件更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"versions-select":{"type":"branches"},"donate":{"alipay":"https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803011956_osChina_支付宝收款码.png","alipayText":"支付宝打赏","button":"打赏","title":"","wechat":"https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803011956_osChina_微信收款码.png","wechatText":"微信打赏"},"fontsettings":{"family":"sans","size":2,"theme":"sepia"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"versions":{"options":[{"value":"https://www.aivin666.cn/java_android/","text":"v1.0"}]},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":false,"google":true,"instapaper":false,"twitter":false,"vk":false,"weibo":true},"edit-link":{"label":"托管页面","base":"https://www.baidu.com/"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/jni/JNI例子.md","mtime":"2019-12-24T00:20:09.454Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-12-24T10:38:14.517Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-versions-select/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

